home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / gnuplot / term / pc.trm < prev    next >
Text File  |  1993-05-11  |  25KB  |  1,429 lines

  1. /*
  2.  * $Id: pc.trm 3.38.2.42 1993/01/07 17:23:59 woo Exp woo $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - pc.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  *
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *  Under Microsoft C
  26.  *      cga, egabios, egalib, vgabios, hercules, corona325, att
  27.  *  Under Turboc C
  28.  *      egalib, vgalib, vgamono, svga, mcga, cga, hercules, att
  29.  *
  30.  * AUTHORS
  31.  *  Colin Kelley, Thomas Williams, William Wilson, Russell Lang
  32.  *
  33.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  34.  *
  35.  */
  36.  
  37. #ifdef __TURBOC__
  38. #include <graphics.h>
  39. #include <conio.h>
  40. #include <dos.h>
  41.   int g_driver, g_mode, g_error;
  42.   char far *path;
  43.   char *pathp, path_s[128];
  44.  
  45. /* instead of string.h */
  46. extern char *strrchr();
  47.  
  48. get_path()
  49. {
  50.    path=(char far *) getenv("BGI");
  51.    if (path==NULL) {
  52.       (void) strcpy(path_s,_argv[0]);
  53.       pathp=strrchr(path_s,'\\');
  54.       *pathp=0x00;
  55.       path=path_s;
  56.    }
  57. }
  58.  
  59. static struct text_info tinfo;       /* So we can restore starting text mode. */
  60. #endif
  61.  
  62.  
  63. static char near buf[80];    /* kludge since EGA.LIB is compiled SMALL */
  64.  
  65. static int pattern[] = {0xffff, 0x0f0f, 0xffff, 0xaaaa, 0x3333, 0x3f3f, 0x0f0f};
  66.  
  67. static int graphics_on = FALSE;
  68. int startx, starty;
  69.  
  70. int pc_angle;
  71. #define PC_VCHAR FNT5X9_VCHAR
  72. #define PC_HCHAR FNT5X9_HCHAR
  73.  
  74. pause()        /* press any key to continue... */
  75. {
  76.     (void) getch();
  77. }
  78.  
  79.  
  80. PC_text()
  81. {
  82.     if (graphics_on) {
  83.         graphics_on = FALSE;
  84.         pause();
  85.     }
  86. #ifdef __TURBOC__
  87.     restorecrtmode();
  88.         textmode(tinfo.currmode);
  89.     clrscr();
  90. #else
  91.     Vmode(3);
  92. #endif
  93. }
  94.  
  95. PC_reset()
  96. {
  97. #ifdef __TURBOC__
  98.     closegraph();
  99.         textmode(tinfo.currmode);
  100.     clrscr();
  101. #endif
  102. }
  103.  
  104.  
  105. #ifndef __TURBOC__
  106.  
  107. PC_putc(x,y,c,angle,line_func)
  108. unsigned int x,y;
  109. char c;
  110. int angle;
  111. FUNC_PTR line_func;
  112. {
  113. int i,j,k;
  114. unsigned int pixelon;
  115.     i = (int)(c) - 32;
  116.     for (j=0; j<FNT5X9_VBITS; j++) {
  117.         for (k=0; k<FNT5X9_HBITS; k++) {
  118.             pixelon = (((unsigned int)(fnt5x9[i][j])) >> k & 1);
  119.             if (pixelon) {
  120.                 switch(angle) {
  121.                     case 0 : (*line_func)(x+k+1,y-j,x+k+1,y-j);
  122.                             break;
  123.                     case 1 : (*line_func)(x-j,y-k-1,x-j,y-k-1);
  124.                             break;
  125.                 }
  126.             }
  127.         }
  128.     }
  129. }
  130.  
  131.  
  132. int PC_text_angle(ang)
  133. int ang;
  134. {
  135.     pc_angle=ang;
  136.     return TRUE;
  137. }
  138.  
  139.  
  140. #define CGA_XMAX 640
  141. #define CGA_YMAX 200
  142.  
  143. #define CGA_XLAST (CGA_XMAX - 1)
  144. #define CGA_YLAST (CGA_YMAX - 1)
  145.  
  146. #define CGA_VCHAR PC_VCHAR
  147. #define CGA_HCHAR PC_HCHAR
  148. #define CGA_VTIC 4
  149. #define CGA_HTIC 6
  150.  
  151. int line_cga;
  152.  
  153. CGA_init()
  154. {
  155.     PC_color(1);        /* monochrome */
  156. }
  157.  
  158. CGA_graphics()
  159. {
  160.     graphics_on = TRUE;
  161.     Vmode(6);
  162. }
  163.  
  164. #define CGA_text PC_text
  165.  
  166. CGA_linetype(linetype)
  167. {
  168.     if (linetype >= 5)
  169.         linetype %= 5;
  170.     line_cga=linetype;
  171.     PC_mask(pattern[linetype+2]);
  172. }
  173.  
  174. CGA_move(x,y)
  175. {
  176.     startx = x;
  177.     starty = y;
  178. }
  179.  
  180.  
  181. CGA_vector(x,y)
  182. {
  183.     PC_line(startx,CGA_YLAST-starty,x,CGA_YLAST-y);
  184.     startx = x;
  185.     starty = y;
  186. }
  187.  
  188.  
  189. CGA_put_text(x,y,str)
  190. unsigned int x, y;
  191. char *str;
  192. {
  193. int i;
  194. int line;
  195.     line= line_cga;     /* disable the dotted lines temporarily */
  196.     PC_mask(pattern[0]);
  197.     switch(pc_angle) {
  198.         case 0 : y -= CGA_VCHAR/2;
  199.                 break;
  200.         case 1 : x += CGA_VCHAR/2;
  201.                 break;
  202.     }
  203.     for (i=0;str[i];i++) {
  204.         PC_putc(x,CGA_YLAST-y,str[i],pc_angle,PC_line);
  205.         switch(pc_angle) {
  206.             case 0 : x+=CGA_HCHAR ;
  207.                     break;
  208.             case 1 : y+=CGA_HCHAR ;
  209.                     break;
  210.         }
  211.     }
  212.     PC_mask(pattern[line]);  /* enable dotted lines */
  213. }
  214.  
  215.  
  216. #define CGA_text_angle PC_text_angle
  217.  
  218. #define CGA_reset PC_reset
  219.  
  220.  
  221. #define EGA_XMAX 640
  222. #define EGA_YMAX 350
  223.  
  224. #define EGA_XLAST (EGA_XMAX - 1)
  225. #define EGA_YLAST (EGA_YMAX - 1)
  226.  
  227. #define EGA_VCHAR PC_VCHAR
  228. #define EGA_HCHAR PC_HCHAR
  229. #define EGA_VTIC 4
  230. #define EGA_HTIC 5
  231.  
  232. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  233. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  234.  
  235. static int *egacolor;
  236.  
  237.  
  238. EGA_init()
  239. {
  240.     PC_mask(0xffff);
  241.     egacolor = ega256color;        /* should be smarter */
  242. }
  243.  
  244. EGA_graphics()
  245. {
  246.     graphics_on = TRUE;
  247.     Vmode(16);
  248. }
  249.  
  250. #define EGA_text PC_text
  251.  
  252. EGA_linetype(linetype)
  253. {
  254.     if (linetype >= 13)
  255.         linetype %= 13;
  256.     PC_color(egacolor[linetype+2]);
  257. }
  258.  
  259. EGA_move(x,y)
  260. {
  261.     startx = x;
  262.     starty = y;
  263. }
  264.  
  265. EGA_vector(x,y)
  266. {
  267.     PC_line(startx,EGA_YLAST-starty,x,EGA_YLAST-y);
  268.     startx = x;
  269.     starty = y;
  270. }
  271.  
  272.  
  273. EGA_put_text(x,y,str)
  274. unsigned int x, y;
  275. char *str;
  276. {
  277. int i;
  278.     switch(pc_angle) {
  279.         case 0 : y -= EGA_VCHAR/2;
  280.                 break;
  281.         case 1 : x += EGA_VCHAR/2;
  282.                 break;
  283.     }
  284.     for (i=0;str[i];i++) {
  285.         PC_putc(x,EGA_YLAST-y,str[i],pc_angle,PC_line);
  286.         switch(pc_angle) {
  287.             case 0 : x+=EGA_HCHAR ;
  288.                     break;
  289.             case 1 : y+=EGA_HCHAR ;
  290.                     break;
  291.         }
  292.     }
  293. }
  294.  
  295.  
  296. #define EGA_text_angle PC_text_angle
  297.  
  298. #define EGA_reset PC_reset
  299.  
  300.  
  301.  
  302. /* The following VGA routines are hacked from the above EGA routines
  303.    They worked on two VGA cards.
  304.    Russell Lang, eln272v@monu1.cc.monash.oz */
  305. #define VGA_XMAX 640
  306. #define VGA_YMAX 480
  307.  
  308. #define VGA_XLAST (VGA_XMAX - 1)
  309. #define VGA_YLAST (VGA_YMAX - 1)
  310.  
  311. #define VGA_VCHAR PC_VCHAR
  312. #define VGA_HCHAR PC_HCHAR
  313. #define VGA_VTIC 5
  314. #define VGA_HTIC 5
  315.  
  316. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  317.  
  318. static int *vgacolor;
  319.  
  320.  
  321. VGA_init()
  322. {
  323.     PC_mask(0xffff);
  324.     vgacolor = vga256color;        /* should be smarter */
  325. }
  326.  
  327. VGA_graphics()
  328. {
  329.     graphics_on = TRUE;
  330.     Vmode(18);
  331. }
  332.  
  333. #define VGA_text PC_text
  334.  
  335. VGA_linetype(linetype)
  336. {
  337.     if (linetype >= 13)
  338.         linetype %= 13;
  339.     PC_color(vgacolor[linetype+2]);
  340. }
  341.  
  342. VGA_move(x,y)
  343. {
  344.     startx = x;
  345.     starty = y;
  346. }
  347.  
  348. VGA_vector(x,y)
  349. {
  350.     PC_line(startx,VGA_YLAST-starty,x,VGA_YLAST-y);
  351.     startx = x;
  352.     starty = y;
  353. }
  354.  
  355.  
  356. VGA_put_text(x,y,str)
  357. unsigned int x, y;
  358. char *str;
  359. {
  360. int i;
  361.     switch(pc_angle) {
  362.         case 0 : y -= VGA_VCHAR/2;
  363.                 break;
  364.         case 1 : x += VGA_VCHAR/2;
  365.                 break;
  366.     }
  367.     for (i=0;str[i];i++) {
  368.         PC_putc(x,VGA_YLAST-y,str[i],pc_angle,PC_line);
  369.         switch(pc_angle) {
  370.             case 0 : x+=VGA_HCHAR ;
  371.                     break;
  372.             case 1 : y+=VGA_HCHAR ;
  373.                     break;
  374.         }
  375.     }
  376. }
  377.  
  378.  
  379. #define VGA_text_angle PC_text_angle
  380.  
  381. #define VGA_reset PC_reset
  382.  
  383.  
  384.  
  385. #ifdef EGALIB
  386.  
  387. #define EGALIB_XMAX 640
  388. #define EGALIB_YMAX 350
  389.  
  390. #define EGALIB_XLAST (EGA_XMAX - 1)
  391. #define EGALIB_YLAST (EGA_YMAX - 1)
  392.  
  393. #define EGALIB_VCHAR 14
  394. #define EGALIB_HCHAR 8
  395. #define EGALIB_VTIC 4
  396. #define EGALIB_HTIC 5
  397.  
  398. #include "mcega.h"
  399.  
  400. EGALIB_init()
  401. {
  402.     GPPARMS();
  403.     if (GDTYPE != 5) {
  404.         term = 0;
  405.         int_error("color EGA board not found",NO_CARET);
  406.     }
  407.     egacolor = (GDMEMORY < 256) ? ega64color : ega256color;
  408. }
  409.  
  410. EGALIB_graphics()
  411. {
  412.     graphics_on = TRUE;
  413.     GPINIT();
  414. }
  415.  
  416. EGALIB_text()
  417. {
  418.     if (graphics_on) {
  419.         graphics_on = FALSE;
  420.         pause();
  421.     }
  422.     GPTERM();
  423. }
  424.  
  425. EGALIB_linetype(linetype)
  426. {
  427.     if (linetype >= 13)
  428.         linetype %= 13;
  429.     GPCOLOR(egacolor[linetype+2]);
  430. }
  431.  
  432. EGALIB_move(x,y)
  433. {
  434.     GPMOVE(x,GDMAXROW-y);
  435. }
  436.  
  437.  
  438. EGALIB_vector(x,y)
  439. {
  440.     GPLINE(x,GDMAXROW-y);
  441. }
  442.  
  443.  
  444. EGALIB_put_text(x,y,str)
  445. int x, y;
  446. char *str;
  447. {
  448.     strcpy((char far *)buf,str);
  449.     GotoXY((int)(x/EGALIB_HCHAR),
  450.            (int)((EGALIB_YMAX-y-(EGALIB_VCHAR/2))/EGALIB_VCHAR));
  451.     gprintf(buf);
  452. }
  453.  
  454.  
  455. #define EGALIB_reset PC_reset
  456.  
  457. #endif /* EGALIB */
  458.  
  459.  
  460. #ifdef HERCULES
  461.  
  462. #define HERC_XMAX 720
  463. #define HERC_YMAX 348
  464.  
  465. #define HERC_XLAST (HERC_XMAX - 1)
  466. #define HERC_YLAST (HERC_YMAX - 1)
  467.  
  468. #define HERC_VCHAR PC_VCHAR
  469. #define HERC_HCHAR PC_HCHAR
  470. #define HERC_VTIC 4
  471. #define HERC_HTIC 5
  472.  
  473. int line_herc;
  474.  
  475. HERC_init()
  476. {
  477.     H_init();
  478. }
  479.  
  480. HERC_graphics()
  481. {
  482.     HVmode(1);
  483.     graphics_on = TRUE;
  484. }
  485.  
  486. HERC_text()
  487. {
  488.     if (graphics_on) {
  489.         graphics_on = FALSE;
  490.         pause();
  491.     }
  492.     HVmode(0);
  493. }
  494.  
  495. HERC_linetype(linetype)
  496. {
  497.     if (linetype >= 5)
  498.         linetype %= 5;
  499.     H_mask(pattern[linetype+2]);
  500.     line_herc = linetype;
  501. }
  502.  
  503. HERC_move(x,y)
  504. {
  505.     if (x < 0)
  506.         startx = 0;
  507.     else if (x > HERC_XLAST)
  508.         startx = HERC_XLAST;
  509.     else
  510.         startx = x;
  511.  
  512.     if (y < 0)
  513.         starty = 0;
  514.     else if (y > HERC_YLAST)
  515.         starty = HERC_YLAST;
  516.     else
  517.         starty = y;
  518. }
  519.  
  520. HERC_vector(x,y)
  521. {
  522.     if (x < 0)
  523.         x = 0;
  524.     else if (x > HERC_XLAST)
  525.         x = HERC_XLAST;
  526.     if (y < 0)
  527.         y = 0;
  528.     else if (y > HERC_YLAST)
  529.         y = HERC_YLAST;
  530.  
  531.     H_line(startx,HERC_YLAST-starty,x,HERC_YLAST-y);
  532.     startx = x;
  533.     starty = y;
  534. }
  535.  
  536.  
  537. HERC_put_text(x,y,str)
  538. unsigned int x, y;
  539. char *str;
  540. {
  541. int i;
  542. int line;
  543.     line= line_herc;     /* disable the dotted lines temporarily */
  544.     H_mask(pattern[0]);
  545.     switch(pc_angle) {
  546.         case 0 : y -= HERC_VCHAR/2;
  547.                 break;
  548.         case 1 : x += HERC_VCHAR/2;
  549.                 break;
  550.     }
  551.     for (i=0;str[i];i++) {
  552.         PC_putc(x,HERC_YLAST-y,str[i],pc_angle,H_line);
  553.         switch(pc_angle) {
  554.             case 0 : x+=HERC_HCHAR ;
  555.                     break;
  556.             case 1 : y+=HERC_HCHAR ;
  557.                     break;
  558.         }
  559.     }
  560.     H_mask(pattern[line]);  /* enable dotted lines */
  561. }
  562.  
  563.  
  564. #define HERC_text_angle PC_text_angle
  565.  
  566. #define HERC_reset PC_reset
  567.  
  568.  
  569. #endif /* HERCULES */
  570.  
  571.  
  572. /* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  573.    ATT 6300 driver */ 
  574.  
  575.  
  576. #ifdef ATT6300
  577.  
  578. #define ATT_XMAX 640
  579. #define ATT_YMAX 400
  580.  
  581. #define ATT_XLAST (ATT_XMAX - 1)
  582. #define ATT_YLAST (ATT_YMAX - 1)
  583.  
  584. #define ATT_VCHAR PC_VCHAR
  585. #define ATT_HCHAR PC_HCHAR
  586. #define ATT_VTIC 4
  587. #define ATT_HTIC 5
  588.  
  589. #define ATT_init CGA_init
  590.  
  591. ATT_graphics()
  592. {
  593.     graphics_on = TRUE;
  594.     Vmode(0x40);        /* 40H is the magic number for the AT&T driver */
  595. }
  596.  
  597. #define ATT_text CGA_text
  598.  
  599. #define ATT_linetype CGA_linetype
  600.  
  601. #define ATT_move CGA_move
  602.  
  603. ATT_vector(x,y)
  604. {
  605.     PC_line(startx,ATT_YLAST-starty,x,ATT_YLAST-y);
  606.     startx = x;
  607.     starty = y;
  608. }
  609.  
  610.  
  611. ATT_put_text(x,y,str)
  612. unsigned int x, y;
  613. char *str;
  614. {
  615. int i;
  616. int line;
  617.     line= line_cga;     /* disable the dotted lines temporarily */
  618.     PC_mask(pattern[0]);
  619.     switch(pc_angle) {
  620.         case 0 : y -= ATT_VCHAR/2;
  621.                 break;
  622.         case 1 : x += ATT_VCHAR/2;
  623.                 break;
  624.     }
  625.     for (i=0;str[i];i++) {
  626.         PC_putc(x,ATT_YLAST-y,str[i],pc_angle,PC_line);
  627.         switch(pc_angle) {
  628.             case 0 : x+=ATT_HCHAR ;
  629.                     break;
  630.             case 1 : y+=ATT_HCHAR ;
  631.                     break;
  632.         }
  633.     }
  634.     PC_mask(pattern[line]);  /* enable dotted lines */
  635. }
  636.  
  637.  
  638. #define ATT_text_angle PC_text_angle
  639.  
  640. #define ATT_reset CGA_reset
  641.  
  642. #endif  /* ATT6300 */
  643.  
  644.  
  645. #ifdef CORONA
  646.  
  647. #define COR_XMAX 640
  648. #define COR_YMAX 325
  649.  
  650. #define COR_XLAST (COR_XMAX - 1)
  651. #define COR_YLAST (COR_YMAX - 1)
  652.  
  653. #define COR_VCHAR PC_VCHAR
  654. #define COR_HCHAR PC_HCHAR
  655. #define COR_VTIC 4
  656. #define COR_HTIC 5
  657.  
  658. int line_cor;
  659.  
  660. static int corscreen;        /* screen number, 0 - 7 */
  661.  
  662. COR_init()
  663. {
  664. register char *p;
  665.     if (!(p = getenv("CORSCREEN")))
  666.         int_error("must run CORPLOT for Corona graphics",NO_CARET);
  667.     corscreen = *p - '0';
  668. }
  669.  
  670. COR_graphics()
  671. {
  672.     graphics_on = TRUE;
  673.     Vmode(3);                /* clear text screen */
  674.     grinit(corscreen);
  675.     grandtx();
  676. }
  677.  
  678. COR_text()
  679. {
  680.     if (graphics_on) {
  681.         graphics_on = FALSE;
  682.         pause();
  683.     }
  684.     grreset();
  685.     txonly();
  686.     Vmode(3);
  687. }
  688.  
  689. COR_linetype(linetype)
  690. {
  691.     if (linetype >= 5)
  692.         linetype %= 5;
  693.     line_cor = linetype;
  694.     Cor_mask(pattern[linetype+2]);
  695. }
  696.  
  697. COR_move(x,y)
  698. {
  699.     if (x < 0)
  700.         startx = 0;
  701.     else if (x > COR_XLAST)
  702.         startx = COR_XLAST;
  703.     else
  704.         startx = x;
  705.  
  706.     if (y < 0)
  707.         starty = 0;
  708.     else if (y > COR_YLAST)
  709.         starty = COR_YLAST;
  710.     else
  711.         starty = y;
  712. }
  713.  
  714. COR_vector(x,y)
  715. {
  716.     if (x < 0)
  717.         x = 0;
  718.     else if (x > COR_XLAST)
  719.         x = COR_XLAST;
  720.     if (y < 0)
  721.         y = 0;
  722.     else if (y > COR_YLAST)
  723.         y = COR_YLAST;
  724.  
  725.     Cor_line(startx,COR_YLAST-starty,x,COR_YLAST-y);
  726.     startx = x;
  727.     starty = y;
  728. }
  729.  
  730.  
  731. COR_put_text(x,y,str)
  732. unsigned int x, y;
  733. char *str;
  734. {
  735. int i;
  736. int line;
  737.     line= line_cor;     /* disable the dotted lines temporarily */
  738.     Cor_mask(pattern[0]);
  739.     switch(pc_angle) {
  740.         case 0 : y -= COR_VCHAR/2;
  741.                 break;
  742.         case 1 : x += COR_VCHAR/2;
  743.                 break;
  744.     }
  745.     for (i=0;str[i];i++) {
  746.         PC_putc(x,COR_YLAST-y,str[i],pc_angle,Cor_line);
  747.         switch(pc_angle) {
  748.             case 0 : x+=COR_HCHAR ;
  749.                     break;
  750.             case 1 : y+=COR_HCHAR ;
  751.                     break;
  752.         }
  753.     }
  754.     COR_mask(pattern[line]);  /* enable dotted lines */
  755. }
  756.  
  757.  
  758. #define COR_text_angle PC_text_angle
  759.  
  760. #define COR_reset PC_reset
  761.  
  762. #endif /* CORONA */
  763.  
  764.  
  765. #else /* ifndef __TURBOC__ */
  766. /* all of the Turbo C routines for the different graphics devices go here */
  767.  
  768. #define VGA_XMAX 640
  769. #define VGA_YMAX 480
  770.  
  771. #define VGA_XLAST (VGA_XMAX - 1)
  772. #define VGA_YLAST (VGA_YMAX - 1)
  773.  
  774. #define VGA_VCHAR 10
  775. #define VGA_HCHAR 8
  776. #define VGA_VTIC 4
  777. #define VGA_HTIC 5
  778.  
  779. #define SVGA_XMAX 640
  780. #define SVGA_YMAX 480
  781.  
  782. #define SVGA_VCHAR 10
  783. #define SVGA_HCHAR 8
  784. #define SVGA_VTIC 4
  785. #define SVGA_HTIC 5
  786.  
  787. static int vga256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  788. static int *vgacolor;
  789.  
  790. static int svga_xmax = SVGA_XMAX,
  791.        svga_ymax = SVGA_YMAX,
  792.        svga_xlast = 639,
  793.        svga_ylast = 479;
  794.  
  795. #define VGA_reset EGALIB_reset
  796. #define VGA_text EGALIB_text
  797. #define VGA_move EGALIB_move
  798. #define VGA_vector EGALIB_vector
  799. #define VGA_text_angle PC_text_angle
  800. #define VGA_justify_text PC_justify_text
  801.  
  802. #define SVGA_reset EGALIB_reset
  803. #define SVGA_text EGALIB_text
  804. #define SVGA_move EGALIB_move
  805. #define SVGA_vector EGALIB_vector
  806. #define SVGA_text_angle PC_text_angle
  807. #define SVGA_justify_text PC_justify_text
  808. #define SVGA_linetype VGA_linetype
  809.  
  810. int PC_text_angle(ang)
  811. int ang;
  812. {
  813.     int size = svga_ymax > 600 ? 2 : 1;
  814.  
  815.     pc_angle = ang;
  816.  
  817.     switch (ang) {
  818.         case 0 : settextstyle(DEFAULT_FONT,HORIZ_DIR,size);
  819.             break;
  820.         case 1 : settextstyle(DEFAULT_FONT,VERT_DIR,size);
  821.             break;
  822.     }
  823.     return TRUE;
  824. }
  825.  
  826. int PC_justify_text(mode)
  827. enum JUSTIFY mode;
  828. {
  829.     switch(mode) {
  830.         case LEFT :
  831.             settextjustify(LEFT_TEXT,CENTER_TEXT);
  832.             break;
  833.         case CENTRE :
  834.             settextjustify(CENTER_TEXT,CENTER_TEXT);
  835.             break;
  836.         case RIGHT:
  837.             settextjustify(RIGHT_TEXT,CENTER_TEXT);
  838.             break;
  839.     }
  840.     return TRUE;
  841. }
  842.  
  843. VGA_init()
  844. {
  845.     g_driver=VGA;
  846.     g_mode=2;
  847.     gettextinfo(&tinfo);
  848.         initgraph(&g_driver,&g_mode,path);
  849.         if(g_driver!=9){
  850.           term=0;
  851.           switch (g_driver){
  852.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  853.                      break;
  854.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  855.                      break;
  856.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  857.                      break;
  858.             case -5: fprintf(stderr,"Insufficient memory to load ",
  859.                              "graphics driver.");
  860.                      break;
  861.             }
  862.  
  863. /*          int_error("color VGA board not found",NO_CARET);*/
  864.         }
  865.         if(g_driver==VGA) vgacolor=vga256color;
  866. }
  867.  
  868. VGA_graphics()
  869. {       g_driver=VGA;
  870.     g_mode=2;
  871.     graphics_on = TRUE;
  872.     gettextinfo(&tinfo);
  873.     setgraphmode(getgraphmode());
  874.     VGA_justify_text(LEFT);
  875. }
  876.  
  877. VGA_linetype(linetype)
  878. {
  879.     if (linetype >= 13)
  880.         linetype %= 13;
  881.     setcolor(vgacolor[linetype+2]);
  882. }
  883.  
  884. VGA_put_text(x,y,str)
  885. unsigned int x, y;
  886. char *str;
  887. {
  888.     strcpy((char far *)buf,str);
  889.     outtextxy(x,VGA_YLAST-y,buf);
  890. }
  891.  
  892.  
  893. VGAMONO_linetype(linetype)
  894. {
  895.     if (linetype >= 5)
  896.         linetype %= 5;
  897.     setlinestyle(4,pattern[linetype+2],1);
  898. }
  899.  
  900. static int huge detect_svga(void)
  901. {
  902.     return g_mode;
  903. }
  904.  
  905. SVGA_init()
  906. {
  907.     char *p, name[128], *SVGA = getenv( "SVGA" );
  908.  
  909.     if (SVGA == NULL)
  910.         int_error("'SVGA' driver environment variable is not set",
  911.               NO_CARET);
  912.  
  913.     strcpy(name, SVGA);
  914.     if ((p = strrchr(name, '.')) == NULL ||
  915.         sscanf(&p[1], "%d", &g_mode) != 1)
  916.         int_error("'SVGA' envvar should be of the form 'name.mode'",
  917.               NO_CARET);
  918.  
  919.     *p = 0;
  920.  
  921.     installuserdriver(name, detect_svga);
  922.     gettextinfo(&tinfo);
  923.     g_driver = 0;
  924.     get_path();
  925.         initgraph(&g_driver,&g_mode,path);
  926.         if(g_driver<0){
  927.           term=0;
  928.           switch (g_driver){
  929.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  930.                      break;
  931.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  932.                      break;
  933.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  934.                      break;
  935.             case -5: fprintf(stderr,"Insufficient memory to load ",
  936.                              "graphics driver.");
  937.                      break;
  938.             }
  939.  
  940.         }
  941.     else
  942.         vgacolor=vga256color;
  943.  
  944.     /* Get the screen size: */
  945.     svga_xmax = term_tbl[term].xmax = getmaxx() + 1;
  946.         svga_ymax = term_tbl[term].ymax = getmaxy() + 1;
  947.     svga_xlast = svga_xmax-1;
  948.     svga_ylast = svga_ymax-1;
  949.  
  950.     if (svga_ymax > 600) {               /* Double the tic/font sizes. */
  951.         term_tbl[term].h_char = SVGA_HCHAR * 2;
  952.         term_tbl[term].v_char = SVGA_VCHAR * 2;
  953.         term_tbl[term].h_tic = SVGA_HTIC * 2;
  954.         term_tbl[term].v_tic = SVGA_VTIC * 2;
  955.         settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  956.      }
  957.     else
  958.         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  959. }
  960.  
  961. SVGA_graphics()
  962. {
  963.     graphics_on = TRUE;
  964.     gettextinfo(&tinfo);
  965.     setgraphmode(getgraphmode());
  966.     VGA_justify_text(LEFT);
  967.  
  968.         svga_ymax = getmaxy() + 1;
  969.     if (svga_ymax > 600)               /* Double the tic/font sizes. */
  970.         settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
  971.     else
  972.         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
  973. }
  974.  
  975. SVGA_put_text(x,y,str)
  976. unsigned int x, y;
  977. char *str;
  978. {
  979.     strcpy((char far *)buf,str);
  980.     outtextxy(x,svga_ylast-y,buf);
  981. }
  982.  
  983. #define MCGA_XMAX 640
  984. #define MCGA_YMAX 480
  985.  
  986. #define MCGA_XLAST (MCGA_XMAX - 1)
  987. #define MCGA_YLAST (MCGA_YMAX - 1)
  988.  
  989. #define MCGA_VCHAR 10
  990. #define MCGA_HCHAR 8
  991. #define MCGA_VTIC 4
  992. #define MCGA_HTIC 5
  993.  
  994. static int *MCGAcolor;
  995.  
  996. #define MCGA_reset EGALIB_reset
  997. #define MCGA_text EGALIB_text
  998. #define MCGA_move EGALIB_move
  999. #define MCGA_vector EGALIB_vector
  1000. #define MCGA_text_angle PC_text_angle
  1001. #define MCGA_justify_text PC_justify_text
  1002.  
  1003. MCGA_init()
  1004. {
  1005.     g_driver=MCGA;
  1006.     g_mode=5;
  1007.     gettextinfo(&tinfo);
  1008.         initgraph(&g_driver,&g_mode,path);
  1009.         if(g_driver!=2){
  1010.           term=0;
  1011.           switch (g_driver){
  1012.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1013.                      break;
  1014.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1015.                      break;
  1016.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1017.                      break;
  1018.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1019.                              "graphics driver.");
  1020.                      break;
  1021.             }
  1022.         }
  1023. }
  1024.  
  1025. MCGA_graphics()
  1026. {
  1027.     graphics_on = TRUE;
  1028.     gettextinfo(&tinfo);
  1029.     setgraphmode(getgraphmode());
  1030.     MCGA_justify_text(LEFT);
  1031. }
  1032.  
  1033.  
  1034. MCGA_put_text(x,y,str)
  1035. unsigned int x, y;
  1036. char *str;
  1037. {
  1038.     strcpy((char far *)buf,str);
  1039.     outtextxy(x,MCGA_YLAST-y,buf);
  1040. }
  1041.  
  1042.  
  1043. MCGA_linetype(linetype)
  1044. {
  1045.     if (linetype >= 5)
  1046.         linetype %= 5;
  1047.     setlinestyle(4,pattern[linetype+2],1);
  1048. }
  1049.  
  1050.  
  1051. #define EGALIB_XMAX 640
  1052. #define EGALIB_YMAX 350
  1053.  
  1054. #define EGALIB_XLAST (EGALIB_XMAX - 1)
  1055. #define EGALIB_YLAST (EGALIB_YMAX - 1)
  1056.  
  1057. #define EGALIB_VCHAR 10
  1058. #define EGALIB_HCHAR 8
  1059. #define EGALIB_VTIC 4
  1060. #define EGALIB_HTIC 5
  1061.  
  1062. static int ega64color[] =  {1,1,5,4,3,5,4,3, 5, 4, 3, 5, 4, 3,5};
  1063. static int ega256color[] = {7,8,2,3,4,5,9,14,12,15,13,10,11,1,6};
  1064.  
  1065. static int *egacolor;
  1066.  
  1067. #define EGALIB_text_angle PC_text_angle
  1068. #define EGALIB_justify_text PC_justify_text
  1069.  
  1070. EGALIB_init()
  1071. {
  1072.     g_driver=EGA;
  1073.     g_mode=1;
  1074.     gettextinfo(&tinfo);
  1075.         initgraph(&g_driver,&g_mode,path);
  1076.         if(g_driver<3 || g_driver>4){
  1077.           term=0;
  1078.           switch (g_driver){
  1079.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1080.                      break;
  1081.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1082.                      break;
  1083.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1084.                      break;
  1085.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1086.                              "graphics driver.");
  1087.                      break;
  1088.             }
  1089.  
  1090. /*          int_error("color EGA board not found",NO_CARET);*/
  1091.         }
  1092.         if(g_driver==EGA) egacolor=ega256color;
  1093.         if(g_driver==EGA64) egacolor=ega64color;
  1094. }
  1095.  
  1096. EGALIB_graphics()
  1097. {
  1098.     graphics_on = TRUE;
  1099.     gettextinfo(&tinfo);
  1100.     setgraphmode(getgraphmode());
  1101.     EGALIB_justify_text(LEFT);
  1102. }
  1103.  
  1104. EGALIB_text()
  1105. {
  1106.     if (graphics_on) {
  1107.         graphics_on = FALSE;
  1108.         pause();
  1109.     }
  1110.     restorecrtmode();
  1111.         textmode(tinfo.currmode);
  1112.     clrscr();
  1113.     svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1114. }
  1115.  
  1116. EGALIB_linetype(linetype)
  1117. {
  1118.     if (linetype >= 13)
  1119.         linetype %= 13;
  1120.     setcolor(egacolor[linetype+2]);
  1121. }
  1122.  
  1123. EGALIB_move(x,y)
  1124. {
  1125.         moveto(x,getmaxy()-y);
  1126. }
  1127.  
  1128.  
  1129. EGALIB_vector(x,y)
  1130. {
  1131.     lineto(x,getmaxy()-y);
  1132. }
  1133.  
  1134.  
  1135. EGALIB_put_text(x,y,str)
  1136. unsigned int x, y;
  1137. char *str;
  1138. {
  1139.     strcpy((char far *)buf,str);
  1140.     outtextxy(x,EGALIB_YLAST-y,buf);
  1141. }
  1142.  
  1143.  
  1144. EGALIB_reset()
  1145. {
  1146.       closegraph();
  1147.         textmode(tinfo.currmode);
  1148.     clrscr();
  1149.     svga_ymax = SVGA_YMAX; /* Since it may double font size if too high. */
  1150. }
  1151.  
  1152.  
  1153. #define CGA_XMAX 640
  1154. #define CGA_YMAX 200
  1155.  
  1156. #define CGA_XLAST (CGA_XMAX - 1)
  1157. #define CGA_YLAST (CGA_YMAX - 1)
  1158.  
  1159. #define CGA_VCHAR 10
  1160. #define CGA_HCHAR 8
  1161. #define CGA_VTIC 4
  1162. #define CGA_HTIC 6
  1163.  
  1164. #define CGA_text_angle PC_text_angle
  1165. #define CGA_justify_text PC_justify_text
  1166. #define CGA_reset PC_reset
  1167.  
  1168. CGA_init()
  1169. {
  1170.     g_driver=CGA;
  1171.     g_mode=4;
  1172.     gettextinfo(&tinfo);
  1173.     initgraph(&g_driver,&g_mode,path);
  1174.           switch (g_driver){
  1175.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1176.                      break;
  1177.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1178.                      break;
  1179.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1180.                      break;
  1181.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1182.                              "graphics driver.");
  1183.                      break;
  1184.             }
  1185. /*    PC_color(1);         monochrome */
  1186.  
  1187. }
  1188.  
  1189. CGA_graphics()
  1190. {
  1191.     graphics_on = TRUE;
  1192.     gettextinfo(&tinfo);
  1193.     setgraphmode(getgraphmode());
  1194.     CGA_justify_text(LEFT);
  1195.     /*    Vmode(6);*/
  1196. }
  1197.  
  1198. #define CGA_text PC_text
  1199.  
  1200. CGA_linetype(linetype)
  1201. {
  1202.     if (linetype >= 5)
  1203.         linetype %= 5;
  1204.     setlinestyle(4,pattern[linetype+2],1);
  1205. }
  1206.  
  1207. CGA_move(x,y)
  1208. {
  1209.     moveto(x,getmaxy()-y);
  1210. }
  1211.  
  1212.  
  1213. CGA_vector(x,y)
  1214. {
  1215.     lineto(x,getmaxy()-y);
  1216. }
  1217.  
  1218. CGA_put_text(x,y,str)
  1219. unsigned int x, y;
  1220. char *str;
  1221. {
  1222.     strcpy((char far *)buf,str);
  1223.     outtextxy(x,CGA_YLAST-y,buf);
  1224. }
  1225.  
  1226.  
  1227.  
  1228. #define HERC_XMAX 720
  1229. #define HERC_YMAX 348
  1230.  
  1231. #define HERC_XLAST (HERC_XMAX - 1)
  1232. #define HERC_YLAST (HERC_YMAX - 1)
  1233.  
  1234. #define HERC_VCHAR 10
  1235. #define HERC_HCHAR 8
  1236. #define HERC_VTIC 4
  1237. #define HERC_HTIC 5
  1238.  
  1239. #define HERC_text_angle PC_text_angle
  1240. #define HERC_justify_text PC_justify_text
  1241. #define HERC_reset PC_reset
  1242.  
  1243. HERC_init()
  1244. {
  1245.     g_driver=HERCMONO;
  1246.     g_mode=0;
  1247.     gettextinfo(&tinfo);
  1248.       initgraph(&g_driver,&g_mode,path);
  1249.           switch (g_driver){
  1250.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1251.                      break;
  1252.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1253.                      break;
  1254.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1255.                      break;
  1256.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1257.                              "graphics driver.");
  1258.                      break;
  1259.             }
  1260. }
  1261.  
  1262. HERC_graphics()
  1263. {
  1264.     gettextinfo(&tinfo);
  1265.     setgraphmode(getgraphmode());
  1266.     HERC_justify_text(LEFT);
  1267.     graphics_on = TRUE;
  1268. }
  1269.  
  1270. HERC_text()
  1271. {
  1272.     if (graphics_on) {
  1273.         graphics_on = FALSE;
  1274.         pause();
  1275.     }
  1276.     restorecrtmode();
  1277.         textmode(tinfo.currmode);
  1278.     clrscr();
  1279. }
  1280.  
  1281. HERC_linetype(linetype)
  1282. {
  1283.     if (linetype >= 5)
  1284.         linetype %= 5;
  1285.     setlinestyle(4,pattern[linetype+2],1);
  1286. }
  1287.  
  1288. HERC_move(x,y)
  1289. {
  1290.     if (x < 0)
  1291.         x = 0;
  1292.     else if (x > HERC_XLAST)
  1293.         x = HERC_XLAST;
  1294.  
  1295.     if (y < 0)
  1296.         y = 0;
  1297.     else if (y > HERC_YLAST)
  1298.         y = HERC_YLAST;
  1299.     moveto(x,getmaxy()-y);
  1300. }
  1301.  
  1302. HERC_vector(x,y)
  1303. {
  1304.     if (x < 0)
  1305.         x = 0;
  1306.     else if (x > HERC_XLAST)
  1307.         x = HERC_XLAST;
  1308.     if (y < 0)
  1309.         y = 0;
  1310.     else if (y > HERC_YLAST)
  1311.         y = HERC_YLAST;
  1312.  
  1313.     lineto(x,getmaxy()-y);
  1314. }
  1315.  
  1316.  
  1317. HERC_put_text(x,y,str)
  1318. unsigned int x, y;
  1319. char *str;
  1320. {
  1321.     strcpy((char far *)buf,str);
  1322.     outtextxy(x,HERC_YLAST-y,buf);
  1323. }
  1324.  
  1325.  
  1326. #ifdef ATT6300
  1327. /* this driver added by rjl@monu1.cc.monash.edu.au */
  1328.  
  1329. #define ATT_XMAX 640
  1330. #define ATT_YMAX 400
  1331.  
  1332. #define ATT_XLAST (ATT_XMAX - 1)
  1333. #define ATT_YLAST (ATT_YMAX - 1)
  1334.  
  1335. #define ATT_VCHAR PC_VCHAR
  1336. #define ATT_HCHAR PC_HCHAR
  1337. #define ATT_VTIC 4
  1338. #define ATT_HTIC 5
  1339.  
  1340. #define ATT_text_angle PC_text_angle
  1341. #define ATT_justify_text PC_justify_text
  1342. #define ATT_reset PC_reset
  1343.  
  1344. ATT_init()
  1345. {
  1346.     g_driver=ATT400;
  1347.     g_mode=5;
  1348.     gettextinfo(&tinfo);
  1349.       initgraph(&g_driver,&g_mode,path);
  1350.           switch (g_driver){
  1351.             case -2: fprintf(stderr,"Graphics card not detected.\n");
  1352.                      break;
  1353.             case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  1354.                      break;
  1355.             case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  1356.                      break;
  1357.             case -5: fprintf(stderr,"Insufficient memory to load ",
  1358.                              "graphics driver.");
  1359.                      break;
  1360.             }
  1361. }
  1362.  
  1363. ATT_graphics()
  1364. {
  1365.     gettextinfo(&tinfo);
  1366.     setgraphmode(getgraphmode());
  1367.     ATT_justify_text(LEFT);
  1368.     graphics_on = TRUE;
  1369. }
  1370.  
  1371. ATT_text()
  1372. {
  1373.     if (graphics_on) {
  1374.         graphics_on = FALSE;
  1375.         pause();
  1376.     }
  1377.     restorecrtmode();
  1378.         textmode(tinfo.currmode);
  1379.     clrscr();
  1380. }
  1381.  
  1382. ATT_linetype(linetype)
  1383. {
  1384.     if (linetype >= 5)
  1385.         linetype %= 5;
  1386.     setlinestyle(4,pattern[linetype+2],1);
  1387. }
  1388.  
  1389. ATT_move(x,y)
  1390. {
  1391.     if (x < 0)
  1392.         x = 0;
  1393.     else if (x > ATT_XLAST)
  1394.         x = ATT_XLAST;
  1395.  
  1396.     if (y < 0)
  1397.         y = 0;
  1398.     else if (y > ATT_YLAST)
  1399.         y = ATT_YLAST;
  1400.     moveto(x,getmaxy()-y);
  1401. }
  1402.  
  1403. ATT_vector(x,y)
  1404. {
  1405.     if (x < 0)
  1406.         x = 0;
  1407.     else if (x > ATT_XLAST)
  1408.         x = ATT_XLAST;
  1409.     if (y < 0)
  1410.         y = 0;
  1411.     else if (y > ATT_YLAST)
  1412.         y = ATT_YLAST;
  1413.  
  1414.     lineto(x,getmaxy()-y);
  1415. }
  1416.  
  1417.  
  1418. ATT_put_text(x,y,str)
  1419. unsigned int x, y;
  1420. char *str;
  1421. {
  1422.     strcpy((char far *)buf,str);
  1423.     outtextxy(x,ATT_YLAST-y,buf);
  1424. }
  1425. #endif /* ifdef ATT6300 */
  1426.  
  1427. #endif /* ifndef __TURBOC__ */
  1428.  
  1429.